#include "exception/spw_stdexcept.h"
//#include "string/spw_string.h"
#include <string.h>

namespace spwstd {
namespace spwexcept {

// RuntimeError
RuntimeError::RuntimeError(const char* msg) {
    ::strncpy(except_msg, msg, 256);
    size_t len = strlen(msg);
    except_msg[len] = '\0';
}

RuntimeError::RuntimeError(const RuntimeError& re) noexcept : Exception(){
    ::strncpy((*this).except_msg, re.except_msg, 256);
}

RuntimeError& RuntimeError::operator=(const RuntimeError& re) noexcept {
    ::strncpy((*this).except_msg, re.except_msg, 256);
    return *this;
} 

// LogicError
LogicError::LogicError(const char* msg) {
    ::strncpy(except_msg, msg, 256);
    size_t len = strlen(msg);
    except_msg[len] = '\0';
}

LogicError::LogicError(const LogicError& re) noexcept : Exception(){
    ::strncpy((*this).except_msg, re.except_msg, 256);
}
LogicError& LogicError::operator=(const LogicError& re) noexcept {
    ::strncpy((*this).except_msg, re.except_msg, 256);
    return *this;
} 
} // namespace myexcept
} // namespace spwstd
